<?php

require_once ('system\core\Controller.php');

class BaseController extends CI_Controller {
	var $DATATYPE_CONTENT ="datatype_context";
	var $DATATYPE_NAV="datatype_nav";
	var $DATATYPE_ASIDE="datatype_aside";
	var $DATATYPE_TRAY="datatype_tray";
	var $DATATYPE_FOOT="datatype_foot";
	var $DATATYPE_ERROR="datatype_error";
	var $MSG_WARNING="msg warning";
	var $MSG_INFO="msg info";
	var $MSG_DONE="msg done";
	var $MSG_ERROR="msg error";
	var $baseControllerData;
	function __construct() {
		parent::__construct ();
		$this->load->helper('url');
		$this->load->library('session'); 
	}
	function index($data =null)
	{
		$this->load->view('mainframework');
	}
	function _loadTrayView()
	{
		if ($this->session->userdata("username"))
		{
			$userinfotmp = $this->session->userdata("username");
			$data["username"] = $userinfotmp;
		}
		else
		{
			$data["username"] = null;
		}
		$this->load->view("app/trayview",$data);
	}
	function _loadNavView()
	{
		$data=null;
		$this->baseControllerData[$this->DATATYPE_NAV]["navindex"] = $this->session->userdata("navindex");
		if (isset($this->baseControllerData[$this->DATATYPE_NAV]))
		{
			$data= $this->baseControllerData[$this->DATATYPE_NAV];
		}
		$this->load->view("app/navview",$data);
	}
	function _loadAsideView()
	{
		$data=null;
		if (isset($this->baseControllerData[$this->DATATYPE_ASIDE]))
		{
			$data= $this->baseControllerData[$this->DATATYPE_ASIDE];
		}
		$this->load->view("app/asideview.php",$data);
	}
	function _loadContentView()
	{
		if (isset($this->baseControllerData[$this->DATATYPE_ERROR]))
		{
			$this->load->view("app/errormsg",$this->baseControllerData[$this->DATATYPE_ERROR]);
			return ;
		}
		$data=null;
		if (isset($this->baseControllerData[$this->DATATYPE_CONTENT]))
		{
			$data= $this->baseControllerData[$this->DATATYPE_CONTENT];
		}

		$this->load->view("app/contentview",$data);
		
	}
	function _loadFootView()
	{
		$data=null;
		if (isset($this->baseControllerData[$this->DATATYPE_FOOT]))
		{
			$data=  $this->baseControllerData[$this->DATATYPE_FOOT];
		}
		$this->load->view("app/footview",$data);
	}
	function showerror($errormsg,$errorurl="",$msgtype="msg error")
	{
		$this->baseControllerData[$this->DATATYPE_ERROR]["errormsg"] = $errormsg;
		$this->baseControllerData[$this->DATATYPE_ERROR]["jumpurl"] = $errorurl;
		$this->baseControllerData[$this->DATATYPE_ERROR]["msgtype"] = $msgtype;
		$this->index();
	}
	function _testuserlogin()
	{
		$username = $this->session->userdata("username");
		if (!empty($username))
		{
			return 0;
		}
		return -1;
	}
	function _testusertype()
	{
		$usertype= $this->session->userdata("usertype");
		if (!empty($usertype))
		{
			return $usertype;
		}
		
		return -1;
	}
}

?>